package com.company.nuwa.redis.common;

import org.springframework.data.redis.serializer.GenericJackson2JsonRedisSerializer;

/**
 * <p>description</p >
 *
 * @author youyoukele
 * @version 1.0
 * @date 2021/7/13
 */
public class JsonRedisSerializer {

    /**
     * @param redisSerializer must not be {@literal null}.
     * @param bytes           can be {@literal null}.
     * @param classType       must not be {@literal null}.
     * @return {@literal null} for empty source.
     */
    public static <T> T deserialize(GenericJackson2JsonRedisSerializer redisSerializer, byte[] bytes, Class<T> classType) {
        try {
            return redisSerializer.deserialize(bytes, classType);
        } catch (Exception e) {
            return null;
        }
    }

}
